<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div id="songControll">
    <a class="loadAll" href="javascript:void(0);">免费下载歌曲</a>
    <a class="playAll" href="javascript:void(0);">播放全部</a>
    <a class="addAll" href="javascript:void(0);">添加</a>
</div>
<ul class="listMusic">
    <%--歌手单曲--%>
<c:forEach items="${musicList}" var="m" varStatus="st">
        <li <c:if test="${st.index % 2 == 1}">class = "even" </c:if> >
                <div class="name">
                    <a href="/lyrics/getLyrics?musicRid=${m.musicRid}">${m.songName}</a>
                </div>
                <div class="artist">
                    <a href="javascript:void(0);">
                        <c:set var="artist" value="${m.artist}"></c:set>
                        <c:choose>
                            <c:when test="${fn:length(artist) > 7}">
                                ${fn:substring(artist,0 ,7)}...
                            </c:when>
                            <c:otherwise>
                                ${artist}
                            </c:otherwise>
                        </c:choose>
                    </a>
                </div>
                <div class="heat">
                    <div class="heatValue" style="width:${m.score}%">
                    </div>
                </div>
                <div class="listRight">
                    <div class="tools">
                        <a class="play playSongArtist" href="/lyrics/getLyrics?musicRid=${m.musicRid}"></a>
                        <a class="add" href="javascript:void(0);" onclick="playVideo('${m.musicRid}')"></a>
                        <a class="down" href="javascript:void(0);"></a>
                        <a class="share" href="javascript:void(0);"></a>
                    </div>
                </div>
            </li>
</c:forEach>
</ul>
<%--分页按钮--%>
<div class="pageComment">
    <!--上一页按钮-->
    <a id="prePage" href="javascript:void(0);" onclick="selectMusic(${page.currentPage - 1})">
        <img src="../image/prev.png">
    </a>
    <!--具体页数按钮-->
    <c:choose>
        <c:when test="${page.totalPage <= 5}">
            <c:forEach begin="1" end="${page.totalPage}" varStatus="st">
                <a href="javascript:void(0);" <c:if test="${st.index == page.currentPage}">class="current"</c:if>
                   onclick="selectMusic(${st.index})">${st.index}</a>
            </c:forEach>
        </c:when>
        <c:otherwise>
            <c:choose>
                <c:when test="${page.currentPage == musicEnd}">
                    <c:set var="musicBegin" value="${page.currentPage}" scope="session"></c:set>
                    <c:choose>
                        <c:when test="${musicEnd == page.totalPage}">
                            <c:set var="musicEnd" value="${page.totalPage}" scope="session"></c:set>
                        </c:when>
                        <c:otherwise>
                            <c:set var="musicEnd" value="${musicEnd + 4}" scope="session"></c:set>
                        </c:otherwise>
                    </c:choose>
                    <c:forEach begin="${musicBegin}" end="${musicEnd}" varStatus="st">
                        <a href="javascript:void(0);" <c:if test="${st.index == page.currentPage}">class="current"</c:if>
                           onclick="selectMusic(${st.index})">${st.index}</a>
                    </c:forEach>
                </c:when>
                <c:otherwise>
                    <c:forEach begin="${musicBegin}" end="${musicEnd}" varStatus="st">
                        <a href="javascript:void(0);" <c:if test="${st.index == page.currentPage}">class="current"</c:if>
                           onclick="selectMusic(${st.index})">${st.index}</a>
                    </c:forEach>
                </c:otherwise>
            </c:choose>
            <span class="point">...</span>
            <a href="javascript:void(0);" <c:if test="${page.totalPage == page.currentPage}">class="current"</c:if>
               onclick="selectMusic(${page.totalPage})">${page.totalPage}</a>
       </c:otherwise>
   </c:choose>
    <!--下一页按钮-->
    <a id="nextPage" href="javascript:void(0);" onclick="selectMusic(${page.currentPage + 1})">
        <img src="../image/next.png">
    </a>
</div>
